﻿using CinemaMaestro.BusinessLayer.Contracts;
using CinemaMaestro.DataLayer.Contracts;
using CinemaMaestro.DataLayer.Contracts.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CinemaMaestro.BusinessLayer
{
    public class Categories : BusinessObjectBase, ICategories
    {
        public Categories(IUnitOfWork uow)
            : base(uow)
        { }

        public Category Create(Category category)
        {
            var createdCategory = _uow.CategoryRepository.Create(category);
            _uow.SaveChanges();
            return createdCategory;
        }

        public bool Delete(int id)
        {
            var deleted = _uow.CategoryRepository.Delete(id);
            _uow.SaveChanges();
            return deleted;
        }

        public IQueryable<Category> Read()
        {
            return _uow.CategoryRepository.Read();
        }

        public void Update(Category entity)
        {
            _uow.CategoryRepository.Update(entity);
            _uow.SaveChanges();
        }
    }
}
